package com.hanter.android.radlib.countdown;

import android.content.Context;
import androidx.annotation.NonNull;

public class CountDownManager {

    @NonNull
    private Context context;
    private CountDownTimerService timerService;

    public CountDownManager(@NonNull Context context) {
        this.context = context.getApplicationContext();
    }

    public void init() {

    }

    /**
     * 创建Timer
     */
    public MyCountDownTimer createTimer(String name, String group, long millisInFuture, long interval) {
        if (timerService == null)
            return null;
        return timerService.createTimer(name, group, millisInFuture, interval);
    }

    /**
     * 删除指定Timer
     */
    public void deleteTimer(String name, String group) {
        if (timerService == null)
            return;
        timerService.deleteTimer(name, group);
    }

    /**
     * 从持久化中获取Timer
     */
    public MyCountDownTimer getTimer(String name, String group) {
        if (timerService == null)
            return null;
        return timerService.getTimer(name, group);
    }

    public void setTimerService(CountDownTimerService timerService) {
        this.timerService = timerService;
    }
}
